{% extends 'base.html' %}

{% block header %}
  <h1>{% block title %}Edit "{{ post['title'] }}"{% endblock %}</h1>
{% endblock %}

{% block content %}
  <form method="post">
    <div class="form-group">
      <label for="title">Title</label>
      <input name="title" id="title" value="{{ request.form['title'] or post['title'] }}" class="form-control" required>
    </div>
    <div class="form-group">
      <label for="body">Body</label>
      <textarea name="body" id="body" class="form-control" rows="10">{{ request.form['body'] or post['body'] }}</textarea>
    </div>
    <button type="submit" class="btn btn-primary">Save</button>
  </form>
  <hr>
  <form action="{{ url_for('blog.delete', pk=post['id']) }}" method="post">
    <button class="btn btn-danger" type="submit" value="" onclick="return confirm('Are you sure?');">Delete</button>
  </form>
{% endblock %}